import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86185
 * Date: 2023-10-21
 * Time: 18:42
 */
public class Exam1020 {
    public static void main(String[] args) {
        int count = 0;
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        String c = scanner.nextLine();
        char t = c.charAt(0);
        t = Character.toLowerCase(t);
        for (int i = 0; i < s.length(); i++) {
            char a = s.charAt(i);
            a = Character.toLowerCase(a);
            if(a == t) {
                count++;
            }
        }
        System.out.println(count);
    }
    public static void main1(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[][] num = new int[2 * n + 1][2 * n + 1];
        num[2][2] = 1;
        if(n <= 2) {
            System.out.println(-1);
        } else {
            for (int i = 3; i <= n + 2 ; i++) {
                for (int j = 2; j <= n + 2 ; j++) {
                    num[i][j] = num[i - 1][j - 2] + num[i - 1][j - 1] + num[i - 1][j];
                }
            }
        }
        for (int i = 2; i <= n + 2; i++) {
            if(num[n + 1][i] % 2 == 0) {
                System.out.println(i - 1);
                return;
            }
        }
    }
}
